package cn.snowheart.strategy.order.handler;

import cn.snowheart.strategy.order.enums.OrderType;

import java.util.HashMap;
import java.util.Map;

/**
 * HandlerContext，以此模拟Spring容器的单例和注入
 *
 * @author liuwanxiang
 * @version 2019/06/24
 */
public class HandlerContext {

    private static Map<OrderType, IOrderHandler> map;

    static {
        map = new HashMap<>();
        map.put(OrderType.NORMAL, new NormalOrderHandler());
        map.put(OrderType.GROUP, new GroupOrderHandler());
        map.put(OrderType.DISCOUNT, new DiscountOrderHandler());
    }

    public static IOrderHandler getHandler(OrderType type) {
        return map.get(type);
    }

}
